package com.neusoft.neuiotms.dcom.repository.incident.impl;

import com.neusoft.bizcore.web.jpa.repository.AbstractRepository;
import com.neusoft.neuiotms.dcom.model.incident.IncidentConfirm;
import com.neusoft.neuiotms.dcom.model.incident.QIncidentConfirm;
import com.neusoft.neuiotms.dcom.repository.incident.CustomizedIncidentConfirmRepository;
import com.querydsl.jpa.impl.JPAQuery;

/**
 * @author WYS
 * @date 2020年8月18日 下午2:10:01
 */
public class CustomizedIncidentConfirmRepositoryImpl extends AbstractRepository
        implements CustomizedIncidentConfirmRepository {

    @Override
    protected Class<?> getModelClass() {
        return IncidentConfirm.class;
    }

    @Override
    public IncidentConfirm findByWorkNum(final String workOrderNum) {
        final QIncidentConfirm qIncidentConfirm = QIncidentConfirm.incidentConfirm;
        final JPAQuery<IncidentConfirm> query = this.query().selectFrom(qIncidentConfirm);
        query.where(qIncidentConfirm.workNum.eq(workOrderNum))
                .orderBy(qIncidentConfirm.createTime.desc()).limit(1);
        return query.fetchOne();
    }

}
